﻿package mortal.game.view.medal.view
{
    import Message.DB.Tables.*;
    import __AS3__.vec.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import extend.language.*;
    import flash.utils.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.resource.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.medal.*;

    public class MedalRightPart extends GSprite
    {
        private var _bg:ScaleBitmap;
        private var _buttomSpLine:ScaleBitmap;
        private var _comBat:BitmapNumberText;
        private var _totalNum:GTextFiled;
        private var _vcAttributeNameText:Vector.<GTextFiled>;
        private var _vcAttributeValueText:Vector.<BitmapNumberText>;
        private var _vcPrivilegeTxt:Vector.<GTextFiled>;

        public function MedalRightPart()
        {
            this._vcAttributeNameText = new Vector.<GTextFiled>;
            this._vcAttributeValueText = new Vector.<BitmapNumberText>;
            this._vcPrivilegeTxt = new Vector.<GTextFiled>;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            var _loc_5:GTextFiled = null;
            var _loc_6:BitmapNumberText = null;
            super.createDisposedChildrenImpl();
            pushUIToDisposeVec(UIFactory.bg(0, 42, 220, 2, this, ImagesConst.SplitLine));
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.medalWinCombatBg, 2.5, 45, this));
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.medalWinTxt_2, 50, 10, this));
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.medalWinTxt_4, 67, 141, this));
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.medalWinTxt_3, 41, 50, this));
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.medalWinTxt_5, 66, 315, this));
            this._buttomSpLine = UIFactory.bg(0, 507, 220, 2, this, ImagesConst.SplitLine);
            var _loc_1:* = UIFactory.gBitmap(ImagesConst.GroupCopySide, -10, 145, this);
            var _loc_2:* = UIFactory.gBitmap(ImagesConst.GroupCopySide, 230, 145, this);
            _loc_2.scaleX = -1;
            this.pushUIToDisposeVec(_loc_2);
            this.pushUIToDisposeVec(_loc_1);
            _loc_1 = UIFactory.gBitmap(ImagesConst.GroupCopySide, -10, 320, this);
            _loc_2 = UIFactory.gBitmap(ImagesConst.GroupCopySide, 230, 320, this);
            _loc_2.scaleX = -1;
            this.pushUIToDisposeVec(_loc_2);
            this.pushUIToDisposeVec(_loc_1);
            this._comBat = UIFactory.bitmapNumberText(110, 84, "WizardCombatNum.png", 23, 30, -3, this, 13, BitmapNumberText.Mid);
            this._comBat.text = "100";
            var _loc_3:* = GlobalStyle.textFormatBai.center();
            _loc_3.size = 14;
            this._totalNum = UIFactory.gTextField(Language.getString(35406), 32, 520, 160, 30, this, _loc_3);
            _loc_3 = GlobalStyle.textFormatAnHuan;
            _loc_3.size = 12;
            var _loc_4:* = MountConfig.instance.attribute;
            var _loc_7:int = 0;
            while (_loc_7 < _loc_4.length)
            {
                
                _loc_5 = UIFactory.gTextField(GameDefConfig.instance.getAttributeName2(_loc_4[_loc_7]), 15 + _loc_7 % 2 * 104, 12 * (_loc_7 - _loc_7 % 2) + 166, 55, 20, this, _loc_3);
                this._vcAttributeNameText.push(_loc_5);
                pushUIToDisposeVec(_loc_5);
                _loc_6 = UIFactory.bitmapNumberText(60 + _loc_7 % 2 * 104, 12 * (_loc_7 - _loc_7 % 2) + 171, "RoleInfoNum.png", 8, 10, -1, this, 14);
                _loc_6.text = "0";
                this._vcAttributeValueText.push(_loc_6);
                pushUIToDisposeVec(_loc_6);
                _loc_7++;
            }
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            if (this._bg)
            {
                this._bg.dispose(param1);
                this._bg = null;
            }
            this._buttomSpLine.dispose(param1);
            this._buttomSpLine = null;
            this._comBat.dispose(param1);
            this._comBat = null;
            this._totalNum.dispose(param1);
            this._totalNum = null;
            this._vcAttributeNameText.length = 0;
            this._vcAttributeValueText.length = 0;
            this.clearPrivilegeTxt();
            super.disposeImpl(param1);
            return;
        }// end function

        public function addBg() : void
        {
            this._bg = UIFactory.bg(-5, 0, 230, 556, this, ImagesConst.MountWinBg);
            this.addChildAt(this._bg, 0);
            return;
        }// end function

        public function updateSize() : void
        {
            var _loc_1:* = this._vcPrivilegeTxt.length * 25 + 342 + 14;
            this._buttomSpLine.y = _loc_1;
            this._totalNum.y = _loc_1 + 6;
            return;
        }// end function

        private function clearPrivilegeTxt() : void
        {
            var _loc_1:GTextFiled = null;
            for each (_loc_1 in this._vcPrivilegeTxt)
            {
                
                _loc_1.dispose(true);
            }
            this._vcPrivilegeTxt.length = 0;
            return;
        }// end function

        private function updatePrivilege(param1:Dictionary) : void
        {
            var _loc_3:GTextFiled = null;
            var _loc_4:int = 0;
            var _loc_6:int = 0;
            var _loc_7:int = 0;
            this.clearPrivilegeTxt();
            var _loc_2:* = MedalConfig.instance.addPrivilegeArr;
            var _loc_5:* = GlobalStyle.textFormatBai.left();
            _loc_5.size = 14;
            while (_loc_7 < _loc_2.length)
            {
                
                _loc_4 = MedalUtil.getTotalValueByName(_loc_2[_loc_7], param1);
                if (_loc_4 > 0)
                {
                    _loc_3 = UIFactory.gTextField("", 15, 25 * _loc_6 + 342, 220, 30, this, _loc_5);
                    _loc_3.htmlText = MedalConfig.instance.translateValueName(_loc_2[_loc_7]) + _loc_4 + "%";
                    this.addChild(_loc_3);
                    this._vcPrivilegeTxt.push(_loc_3);
                    _loc_6++;
                }
                _loc_7++;
            }
            return;
        }// end function

        private function getMedalNum(param1:Dictionary) : int
        {
            var _loc_2:int = 0;
            var _loc_3:TMedal = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2++;
            }
            return _loc_2;
        }// end function

        public function updateMedal(param1:Dictionary) : void
        {
            var _loc_4:int = 0;
            var _loc_2:* = MountConfig.instance.attribute;
            var _loc_3:* = _loc_2.length;
            var _loc_5:int = 0;
            while (_loc_5 < _loc_3)
            {
                
                this._vcAttributeValueText[_loc_5].text = MedalUtil.getTotalValueByName(_loc_2[_loc_5], param1).toString();
                _loc_5++;
            }
            this._totalNum.htmlText = Language.getString(35406) + "<font color = \'#fd992f\'>[" + this.getMedalNum(param1) + "/" + MedalConfig.instance.totalMedalNum + "]</font>";
            this._comBat.text = MedalUtil.getMedalTotalComabtByMedals(param1).toString();
            this.updatePrivilege(param1);
            return;
        }// end function

    }
}
